import request from './axios'

// 创建订单
export function createOrder(data) {
  return request({
    url: '/api/orders',
    method: 'post',
    data
  })
}

/**
 * 获取用户订单列表
 * @param {string} userId 用户ID
 * @returns {Promise<Array>} 订单列表
 */
export const getUserOrders = (userId) => {
  return request.get(`/api/orders/orders/${userId}`)
}

/**
 * 获取订单详情
 * @param {string} orderId 订单ID
 * @returns {Promise<Object>} 订单详情
 */
export const getOrderDetail = (orderId) => {
  return request.get(`/api/orders/${orderId}`)
}

// 更新订单状态
export function updateOrderStatus(orderId, status) {
  return request({
    url: `/api/orders/${orderId}/status`,
    method: 'put',
    data: { status }
  })
}

/**
 * 取消订单
 * @param {string} orderId 订单ID
 * @returns {Promise}
 */
export const cancelOrder = (orderId) => {
  return request.post(`/api/orders/${orderId}/cancel`)
} 